﻿<UserControl x:Class="Marss.JsonViewer.Views.DefaultViewerControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Marss.JsonViewer.Views"
             xmlns:utils="clr-namespace:Marss.JsonViewer.ViewModels.Utils"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <DockPanel Grid.Row="0" LastChildFill="True">
            <Button DockPanel.Dock="Right" Margin="3" Command="{Binding PrintCommand}" CommandParameter="{Binding Path=., ElementName=Browser}">
                <TextBlock Margin="3 0">Print</TextBlock>
            </Button>
            <Button DockPanel.Dock="Right" Margin="3"  Command="{Binding FormatProgrammerFriendlyCommand}" CommandParameter="{Binding Path=., ElementName=Browser}">
                <TextBlock Margin="3 0">Programmer-friendly Format</TextBlock>
            </Button>
            <Button DockPanel.Dock="Right" Margin="3" Command="{Binding FormatHumanFriendlyCommand}" CommandParameter="{Binding Path=., ElementName=Browser}">
                <TextBlock Margin="3 0">Human-friendly Format</TextBlock>
            </Button>
            <TextBlock Margin="3" HorizontalAlignment="Left">Paste JSON data:</TextBlock>
        </DockPanel>

        <TextBox TextWrapping="Wrap" AcceptsReturn="True" Grid.Row="1"  Height="100"
                 VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                 Text="{Binding UnformattedJson, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="3"></TextBox>

        <Border Grid.Row="2"  BorderBrush="LightGray" BorderThickness="1" Margin="3">
            <WebBrowser x:Name="Browser" utils:WebBrowserUtility.BindableSource="{Binding ResourcePath}"></WebBrowser>
        </Border>

    </Grid>
</UserControl>
